﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace Test_Drag_N_drop
{
    public class  BlockPoolZone
    {
        private static Rectangle myBox;
        private List<ButtonBlock> availableBlockList;
        private Texture2D backTexture;

        public void Initialize(GraphicsDevice graphic, int sW, int sH)
        {
            myBox = new Rectangle((int)sW * 2 / 3, 0, (int)sW / 3, sH);
            availableBlockList = new List<ButtonBlock>();
            availableBlockList.Add(new ButtonBlock(TypeOfBlock.UP));
            availableBlockList.Add(new ButtonBlock(TypeOfBlock.DOWN));
            availableBlockList.Add(new ButtonBlock(TypeOfBlock.RIGHT));
            availableBlockList.Add(new ButtonBlock(TypeOfBlock.LEFT));
            availableBlockList.Add(new ButtonBlock(TypeOfBlock.END));

            int x = myBox.X + myBox.Width / 2;
            int y = 80;
            foreach (ButtonBlock block in availableBlockList)
            {
                block.Initialize(x, y);
                y += 100;
            }


        }

        public void LoadContent(ContentManager content)
        {
            backTexture = content.Load<Texture2D>("poolpanel");
            foreach (ButtonBlock block in availableBlockList)
            {
                block.LoadContent(content);
            }
        }
          
        public void Update(GameTime gameTime, MouseState ms, MouseState pms)
        {
            foreach (ButtonBlock block in availableBlockList)
            {
                block.Update(gameTime, ms, pms);
            }
        }

        public virtual void Draw(SpriteBatch spriteBatch, GameTime gameTime)
        {
            spriteBatch.Draw(backTexture, myBox, Color.White);
            foreach (ButtonBlock block in availableBlockList)
            {
                block.Draw(spriteBatch, gameTime);
            }
        }

       public static bool isIn(Rectangle rect)
        {
           if (myBox.X < rect.X)
           {
               return true;
           }
           else
           {
               return false;
           }
               
        }

    }
}
